﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using BLL;
using System.Web.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Text;

public partial class Plublic_Cards : System.Web.UI.Page
{
    String StrConn = WebConfigurationManager.ConnectionStrings["conn"].ConnectionString.ToString();
    CardTypeHandler objCardTypeHandler = new CardTypeHandler();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) { 
        
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {

        if (txtNameCard.Text != string.Empty)
        {
            CardType objCardType = new CardType();

            objCardType.Created = DateTime.Now.ToString();
            objCardType.Updated = DateTime.Now.ToString();
            objCardType.Isactive = "1";
            objCardType.Name = txtNameCard.Text.ToString();
            objCardType.Descriptions = txtDescription.Text.ToString();

            objCardTypeHandler.AddNewCardType(objCardType, StrConn);
            this.setText();
        }
        else
        {
            string messagebox = "Error, please try again...!!!";
            StringBuilder stringbuilder = new StringBuilder();
            stringbuilder.Append("<script language='javascript'>");
            stringbuilder.Append("alert(\"" + messagebox + "\");");
            stringbuilder.Append("<" + "/script>");
            Response.Write(stringbuilder.ToString());
        }
    }

    protected void setText() 
    {
        this.txtNameCard.Text = "";
        this.txtDescription.Text = "";
    }
}